package hyskidotmateuszatgmail.recepcja;


import android.app.ActionBar;
import android.app.FragmentTransaction;
import android.app.ActionBar.Tab;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;

/*import com.example.androidhive.KlasaStatyczna;
import com.example.androidhive.Kolejki;
import com.example.androidhive.R;*/

import hyskidotmateuszatgmail.recepcja.adapter.KlasaStatyczna;
import hyskidotmateuszatgmail.recepcja.adapter.TabsPagerAdapter;


public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {

private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
/*private */
public static String[] tabs = { "Top Rated", "Games", "Movies" ,"Lokalizacje"};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
KlasaStatyczna.readProperties();
setContentView(R.layout.activity_main);

//set application context
//KlasaStatyczna.setAct(getA);
KlasaStatyczna.setContext(this/*getApplicationContext()*/);

// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
System.out.println("a");
//Kolejki.get().add();
// Adding Tabs
for (String tab_name : tabs) {
	actionBar.addTab(actionBar.newTab().setText(tab_name)
			.setTabListener(this));
}

/**
 * on swiping the viewpager make respective tab selected
 * */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

	@Override
	public void onPageSelected(int position) {
		// on changing the page
		// make respected tab selected
		actionBar.setSelectedNavigationItem(position);
	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
	}

	@Override
	public void onPageScrollStateChanged(int arg0) {
	}
});
}

@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}

@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
 /**
  * On first tab we will show our list
  */
/*  if (tab.getPosition() == 0) {
  //MyFriendsListFragment simpleListFragment = new MyFriendsListFragment();
  getSupportFragmentManager().beginTransaction().replace(R.id.fragment_games, simpleListFragment).commit();
 }
 else if (tab.getPosition() == 1) {
  AndroidList androidlidt = new AndroidList();
  getSupportFragmentManager().beginTransaction().replace(R.id.container, androidlidt).commit();
}
 else {
  AndroidVersionList androidversionlist = new AndroidVersionList();
  getSupportFragmentManager().beginTransaction().replace(R.id.container, androidversionlist).commit();
 }*/
}

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}

}
